{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "772ca5a4-c365-4859-a064-02bb23a160b1",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "集合的内容、长度、最大值、最小值分别为：\n",
      "{1, 2, 3, 4, 5, 6, 9} 7 9 1\n",
      "{0, 1, 2, 4, 5, 7, 9, 10} 8 10 0\n",
      "A和B的并集、交集和差集分别为：\n",
      "{0, 1, 2, 3, 4, 5, 6, 7, 9, 10} {1, 2, 4, 5, 9} {3, 6}\n"
     ]
    }
   ],
   "source": [
    "import random\n",
    "A=set()\n",
    "for i in range(10):\n",
    "    A.add(random.randint(0,10))  #随机产生一个0~10的整数，添加到A\n",
    "B=set()\n",
    "for i in range(10):\n",
    "    B.add(random.randint(0,10))  #随机产生一个0~10的整数，添加到B\n",
    "print(\"集合的内容、长度、最大值、最小值分别为：\")\n",
    "print(A,len(A),max(A),min(A))\n",
    "print(B,len(B),max(B),min(B))\n",
    "print(\"A和B的并集、交集和差集分别为：\")\n",
    "print(A|B,A&B,A-B)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "69cb5620-319d-4e22-9b12-b4f081fe2129",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
